home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / TURB_VIS / TVG121 / STYX.PAS < prev    next >
Pascal/Delphi Source File  |  1994-05-27  |  2KB  |  111 lines

  1. {************************************************}
  2. { STYX DEMO FOR TVDEMO, using TVGRAPH            }
  3. {************************************************}
  4.  
  5. unit Styx;
  6.  
  7. {$F+,O-,X+,S-,D+,L+}
  8.  
  9. { Graphics Styx demo }
  10.  
  11. interface
  12.  
  13. uses TvGraph, DemoCmds, Objects, App, Views, Drivers;
  14.  
  15. const
  16.  cmStyx=1100;
  17. type
  18.   PStyx = ^TStyx;
  19.   TStyx = object(gObject)
  20.     CurrentStick:byte;
  21.     StyxLocations:Array[0..15] of gLine;
  22.     vXA,vYA,vXB,vYB:integer;
  23.     constructor Init;
  24.     procedure GraphProd; virtual;
  25.     procedure GraphDraw(R:TRect); virtual;
  26.   end;
  27.  
  28.   PStyxDemo = ^TStyxDemo;
  29.   TStyxDemo = object(gWindow)
  30.     constructor Init;
  31.   end;
  32.  
  33. implementation
  34.  
  35. constructor TStyx.Init;
  36. var
  37.  C:word;
  38. begin
  39.  CurrentStick:=0;
  40.  for C:=0 to 15 do
  41.     Styxlocations[C].Init(GraphXMax div 3,GraphYMax div 3,
  42.                           GraphXMax div 2,GraphYMax div 2,15);
  43.  vXA:=random(8)+1;if vXA>4 then vXA:=4-vXA;
  44.  vXA:=vXA*16;
  45.  vYA:=random(8)+1;if vYA>4 then vYA:=4-vYA;
  46.  vYA:=vYA*16;
  47.  vXB:=random(8)+1;if vXB>4 then vXB:=4-vXB;
  48.  vXB:=vXB*16;
  49.  vYB:=random(8)+1;if vYB>4 then vYB:=4-vYB;
  50.  vYB:=vYB*16;
  51.  
  52.  for C:=1 to 16 do GraphProd;
  53. end;
  54.  
  55. procedure TStyx.GraphDraw(R:TRect);
  56. const
  57.  StyxColor:array[0..15] of byte =(15,11,11,9,9,9,9,1,1,1,1,1,1,1,1,0);
  58. var
  59.  Count:byte;
  60.  Actual:byte;
  61. begin
  62.  for count:=0 to 15 do
  63.  begin
  64.     Actual:=(16-Count+CurrentStick) mod 16;
  65.     begin
  66.      Styxlocations[Count].ChangeColor(StyxColor[Actual]);
  67.      Styxlocations[Count].GraphDraw(R);
  68.     end;
  69.   end;
  70. end;
  71.  
  72. procedure TStyx.GraphProd;
  73. var
  74.  Count:byte;
  75.  LS:byte;
  76. begin
  77.  LS:=CurrentStick;
  78.  CurrentStick:=(CurrentStick+1) mod 16;
  79.  with Styxlocations[CurrentStick] do
  80.    begin
  81.       ChangeEndsCopy(StyxLocations[LS]);
  82.       DeltaEnds(vXa,vYa,vXb,vYb);
  83.       if (XA=0) or (XA=GraphXMax) then vXa:=-vXa;
  84.       if (YA=0) or (YA=GraphYMax) then vYa:=-vYa;
  85.       if (XB=0) or (XB=GraphXMax) then vXb:=-vXb;
  86.       if (YB=0) or (YB=GraphYMax) then vYb:=-vYb;
  87.    end;
  88. end;
  89.  
  90. constructor TStyxDemo.Init;
  91. var
  92.   R  : TRect;
  93.   GV : pgView;
  94.   PB : pStyx;
  95. begin
  96.   R.Assign(0, 0, 34, 12);
  97.   TWindow.Init(R, 'S T Y X', wnNoNumber);
  98.   GetExtent(R);
  99.   R.Grow(-1,-1);
  100.   GV:=New(pgView,Init(R));
  101.   PB:=New(pStyx,Init);
  102.   if (GV<>nil) and (PB<>nil) then
  103.     begin
  104.      GV^.Insert(PB);
  105.      Insert(GV);
  106.     end else if GV<>nil then Dispose(GV,Done)
  107.                         else Dispose(PB,Done);
  108. end;
  109.  
  110. end.
  111.